/*
* @Author: xfy
* @Date:   2017-09-07 08:02:05
* @Last Modified by:   xfy
* @Last Modified time: 2017-09-07 09:31:39
*/
'use strict';
require('./index.css');
var _supper         = require('util/supper.js');
var _userAdmin      = require('service/admin-user-service.js');
//导航
var adminNav = {
    init : function(){
        this.bindEvent();
        this.loadUserInfo();
        return this;
    },
    bindEvent : function(){
        //退出点击事件
        $('.admin-nav .js-logout').click(function(){
            _userAdmin.logout(function(res){
                window.location.reload();
            }, function(errMsg){
                _supper.errorTips(errMsg);
            });
        });
    },
    //加载用户信息
    loadUserInfo : function(){
        _userAdmin.checkLogin(function(res){
            //登录成功就隐藏
            $('.admin-nav .username').text(res.username);
        }, function(errMsg){
            
        });
    }
}
module.exports = adminNav.init();